import 'dart:collection';

import 'package:aio/aio.dart';
import 'package:app/src/config/app_data_config.dart';
import 'package:app/src/http/bean/user.dart';
import 'package:app/src/http/bean/works_2023/commission_bean.dart';
import 'package:app/src/http/bean/works_2023/contractroyaltyrateapplycheck_bean.dart';
import 'package:app/src/http/bean/works_2023/material_review_info.dart';
import 'package:app/src/http/bean/works_2023/purcontract_bean.dart';
import 'package:app/src/http/bean/works_2023/purorderInfo_bean.dart';
import 'package:app/src/http/bean/works_2023/report_loss_bean.dart';
import 'package:app/src/http/bean/works_2023/transport_bean.dart';
import 'package:app/src/http/bean/worksdo/equipment_management_bean.dart';
import 'package:app/src/http/bean/worksdo/material_requisition_bean.dart';
import 'package:app/src/http/bean/wroks/address_bean.dart';
import 'package:app/src/http/bean/wroks/attachment_bean.dart';
import 'package:app/src/http/bean/wroks/carfreightrates_bean.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/http/bean/wroks/contract_paymenttermscopy.dart';
import 'package:app/src/http/bean/wroks/customers_copyInfo.dart';
import 'package:app/src/http/bean/wroks/delivery_notice.dart';
import 'package:app/src/http/bean/wroks/nodelist_bean.dart';
import 'package:app/src/http/bean/wroks/oem_auditing_bean.dart';
import 'package:app/src/http/bean/wroks/oem_auditing_product_bean.dart';
import 'package:app/src/http/bean/wroks/order_item_info.dart';
import 'package:app/src/http/bean/wroks/pay_free.dart';
import 'package:app/src/http/bean/wroks/pay_notice_bean.dart';
import 'package:app/src/http/bean/wroks/payfree_return_bean.dart';
import 'package:app/src/http/bean/wroks/product_bean.dart';
import 'package:app/src/http/bean/wroks/receipt_bean.dart';
import 'package:app/src/http/bean/wroks/special_clauses.dart';
import 'package:app/src/http/bean/wroks/sub_payfree_good_return.dart';
import 'package:app/src/http/bean/wroks/sub_payfree_return.dart';
import 'package:app/src/http/bean/wroks/workreview_bean.dart';

import 'wroks/customers_copyInfo.dart';

//fixme 子类调用案例（有泛型）;如果数据结构比较复杂，有很多的泛型，我们可以使用多个动态类型dynamic;
//fixme 支持多个动态类型，用法和泛型一样。
class AppHttpResult<T, T2> extends BaseBean {
  /**
   * fixme 泛型，在赋值符号=前面声明类型，能够知道类型。能够读取属性。
   * fixme 泛型在方法里（泛型方法），也能知道具体类型。
   * fixme 泛型在不指明的情况下，默认就是dynamic动态类型。
   */
  T? Data;

  /**
   * fixme 当泛型T类型为List对象时，t2为List里面具体的类型。如果T是一个普通实体类不是List。则t2随便指定成String类型即可。即：t2=''
   */
  T2? t2;

  String? MsgCode;
  String? MsgDetail;
  String? StockNum; //物料请购，物料库存。

  String? Res = "false"; //设备管理

  //this构造函数，对泛型初始赋值。便于解析。
  AppHttpResult({this.Data, this.t2}) {}

  int? Num; //插入到第几位 ,原片领用需领个数
  String? Code; //服务器返回的密钥
  int MaxPage = 0; //最大页数
  int TotalNum = 0; //总数据个数
  int TotalRowCount = 0; //总数据个数（物料请购）

  ///判断是否成功，数据不能为空。
  bool isSuccessForData() {
    if (isSuccessForCode() && Data != null) {
      //数据不能为空
      String str = Data.toString().trim();
      if (str.length > 0 && str != "[]" && str != "{}") {
        return true;
      }
      return false;
    }
    return false;
  }

  ///判断是否成功，只判断Code，不判断数据是否为空。
  bool isSuccessForCode() {
    var b = false;
    if (MsgCode != null && MsgCode == MsgCodes.code_100) {
      b = true;
    }
    return b;
  }

  ///判断打卡签退，是否需要二次确认。
  bool isSuccessForCode102() {
    var b = false;
    if (MsgCode != null && MsgCode == MsgCodes.code_102) {
      b = true;
    }
    return b;
  }

  ///判断打卡签退二次确认后，是否还需要接口判断一次。fixme 现在已经没有103了，不需要判断。
  ///打卡签退成功后；102 跳转到当日结算 103跳转到 本次结算
  bool isSuccessForCode103() {
    var b = false;
    if (MsgCode != null && MsgCode == MsgCodes.code_103) {
      b = true;
    }
    return b;
  }

  ///判断打卡签退，是否需要二次确认。（我的工单，工单领用，五金领用申请的二次确认。）
  bool isSuccessForCode101WithHardware() {
    var b = false;
    if (MsgCode != null && MsgCode == "101") {
      b = true;
    }
    return b;
  }

  @override
  instance() {
    // TODO: implement instance
    //throw UnimplementedError();
    return AppHttpResult();
  }

  AppHttpResult.fromJson(dynamic json) {
    fromJson(json);
  }

  ///fixme 合同审核
  ContractCopyInfo? ContractInfo = null; //合同审核（基本信息）
  CustomersCopyInfo? CustomersInfo = null; //客户信息
  ContractPaymentTerms? ContractPaymentTermsCopy = null; //付款方式
  ContractPaymentTerms? ContractFinalPaymentCopy = null; //末批发货

  List<SpecialClauses>? SpecialClausesList = null; //特殊加工
  List<Attachment>? FileList = null; //附件
  List<Product>? ProductList = null; //产品信息
  List<NodeLog>? NodeList = null; //审核日志

  ///fixme 订单审核
  Product? OrderInfo = null; //订单审核里的产品信息。
  List<OrderItemInfo>? OrderItemList = null; //订单审核条目信息。

  ///fixme 送货地址审核
  List<Address>? AddressList = null;

  ///fixme 合同特殊设置审核
  List<OemAuditing>? OemAuditingList = null;
  String? IsUseOemAuditing =
      null; //1启用，非1都是不启用;(启用合同特殊设置信息)；fixme 审核人只能审核，不能修改是否选中的状态。

  ///fixme 合同特殊设置审核产品信息
  List<OemAuditingProduct>? OemAuditingProductList = null;

  ///判断是否启用合同特殊设置
  bool isUseOemAuditing() {
    return BoolUtils.isBoolWithStr(IsUseOemAuditing);
  }

  ///设置合同特殊设置
  void setUseOemAuditing(bool? b) {
    if (BoolUtils.isBool(b)) {
      IsUseOemAuditing = "1";
    } else {
      IsUseOemAuditing = "0";
    }
  }

  ///fixme 更换工厂审核
  ///"ChangeFactoryId": "2",
  ///"ChangeFactoryName": "明州玻璃（洞桥）",
  String? ChangeFactoryId = null;
  String? ChangeFactoryName = null;

  ///fixme 确认收款
  PayNotice? PayNoticeInfo = null; //通知单信息
  List<PayNoticeDetail>? PayNoticeDetails = null; //收款明细

  ///fixme 开票审核
  ReceiptBean? Receipt = null; //开票信息
  List<ReceiptDetail>? ReceiptDetails = null; //已开发票
  List<ReceiptItem>? ReceiptItemList = null; //申请条目

  ///fixme 免款审核
  PayFree? PayFreeInfo = null; //免款信息
  List<PayFreeDetail>? PayFreeDetails = null; //免款明细

  List<String>? PicList = null; //fixme 图片证据
  List<NodeShow>? BackToUserInfoList = null; //fixme 审核退回至
  NodeShow? BackToUserInfo = null; //fixme 退回人，这个是自己加的，用于记录当前选中的退回人。

  ///fixme 退货审核
  PayFreeReturnBean? PayFreeReturn = null; //退货信息
  PayFreeReturnDetail1? PayFreeReturnList = null; //退货审核明细
  List<PayFreeGoodReturn>? PayFreeGoodReturnList = null; //退货补片明细
  List<PayFreeReturnInfo>? PayFreeReturnInfoList = null; //退货审核详情（已审核）

  ///fixme 发货审核
  DeliveryNotice? DeliveryInfo = null; //通知单信息
  DeliveryList1? DeliveryList = null; //发货明细

  //fixme 派工审核；申请信息
  ContractCopyInfo? OtherWorkApply = null;

  //fixme 外车运费审核
  CarFreightRates? CarFreight = null;

  //fixme 加班审核
  ContractCopyInfo? WorkReview = null; //加班审核：人员信息
  List<Scheduling>? Schedulings = null; //排班
  List<WorkOvertimeApproval>? WorkOvertimeApprovals = null; //加班审批
  List<List<WorkOvertimeApproval>>? _workOvertimeApprovalListDatas = null;

  List<List<WorkOvertimeApproval>>? getWorkOvertimeApprovals() {
    if (_workOvertimeApprovalListDatas != null &&
        _workOvertimeApprovalListDatas!.length > 0) {
      return _workOvertimeApprovalListDatas;
    }
    //List转List<List>
    Map<String, List<WorkOvertimeApproval>> map = HashMap();
    WorkOvertimeApprovals?.forEach((element) {
      String key1 = element.Flightdate ?? ""; //班次日期
      String key2 = element.ShiftName ?? ""; //班次名称
      String key = key1 + key2;
      List<WorkOvertimeApproval>? datas = map[key];
      //print("班次日期：$key  $datas");
      if (datas != null) {
        datas?.add(element);
      } else {
        datas = [];
        datas?.add(element);
      }
      map[key] = datas;
    });
    _workOvertimeApprovalListDatas = [];
    map.forEach((key, value) {
      _workOvertimeApprovalListDatas?.add(value);
    });
    return _workOvertimeApprovalListDatas;
  }

  //fixme 物料请购
  MaterialInfo? Material = null;

  //fixme 提成审核
  PercentageCheckBean? PercentageCheck = null;

  ///fixme 提成比例审核
  ContractRoyaltyRateApplyCheckBean? ContractRoyaltyRateApplyCheck = null;

  ///"addresslis": "01,工厂,宁波市鄞州区浙大宁波理工学院|",
  ///fixme 提成比例审核 -> 合同信息 -> 送货地址
  String? addresslis = null;

  //获取送货地址
  List<String> getAddresslis() {
    var _list = <String>[];
    if (StringUtils.isNotEmpty(addresslis)) {
      addresslis?.split("|").forEach((element) {
        var _list2 = element.split(",");
        if (_list2.length >= 3) {
          _list.add("(${_list2[1]})${_list2[2]}"); //如：(工厂)宁波市鄞州区浙大宁波理工学院
        }
      });
    }
    return _list;
  }

  ///fixme 提成比例审核 -> 合同信息 -> 送货路线
  List<ContractFreightInfo>? ContractFreightInfoList = null;

  ///fixme 报损审核
  FLoseApplyInfoBean? FLoseApplyInfo = null;

  ///fixme 五金领用审核
  List<MaterialReviewInfoBean>? MaterialReviewInfo = null;

  ///fixme 请购单审核
  ContractCopyInfo? PurDemandInfo = null;

  ///fixme 采购单审核
  PurOrderInfoBean? PurOrderInfo = null;

  ///fixme 采购合同审核
  PurContractBean? PurContract = null;

  ///fixme 采购合同审核(用于对比)
  PurContractBean? PurContractCompare = null;

  ///fixme 运输合同审核
  LogisticsContractBean? LogisticsContract = null;

  List<EquipmentInfo>? TicketCenter = null; //工单中心
  List<EquipmentInfo>? Myworkorder = null; //我的工单

  //fixme fromJson自动生成的是构造函数，这里改成普通函数。正常方便调用。
  //fixme 建议一般字段类型最好都为String类型，兼容性好。
  void fromJson(Map json) {
    // print("====================json:${json}");
    Res = json["Res"].toString() ?? "false";
    MsgCode = json["MsgCode"].toString() ?? "";
    MsgDetail = json["MsgDetail"].toString() ?? "";
    StockNum = json["StockNum"].toString() ?? "";
    Code = json["Code"] ?? "";
    Num = json["Num"] ?? 0;
    MaxPage = json["MaxPage"] ?? 0;
    TotalNum = json["TotalNum"] ?? 0;
    TotalRowCount = json["TotalRowCount"] ?? 0;
    //fixme 泛型解析(防止String类型数据不同步,必须重新赋值。)
    //fixme 多个动态类型，也是一样的调用方式。支持多个动态类型。
    Data = setGenericFromJson(json, 'Data', Data, t2);
    Material = setGenericFromJson(json, 'Material', MaterialInfo(), "");
    ContractInfo =
        setGenericFromJson(json, 'ContractInfo', ContractCopyInfo(), "");
    LogisticsContract = setGenericFromJson(
        json, 'LogisticsContract', LogisticsContractBean(), "");
    WorkReview = setGenericFromJson(json, 'WorkReview', ContractCopyInfo(), "");
    CustomersInfo =
        setGenericFromJson(json, 'CustomersInfo', CustomersCopyInfo(), "");
    ContractPaymentTermsCopy = setGenericFromJson(
        json, 'ContractPaymentTermsCopy', ContractPaymentTerms(), "");
    ContractFinalPaymentCopy = setGenericFromJson(
        json, 'ContractFinalPaymentCopy', ContractPaymentTerms(), "");
    SpecialClausesList = setGenericFromJson(
        json, 'SpecialClausesList', <SpecialClauses>[], SpecialClauses());
    FileList =
        setGenericFromJson(json, 'FileList', <Attachment>[], Attachment());
    ProductList =
        setGenericFromJson(json, 'ProductList', <Product>[], Product());
    NodeList = setGenericFromJson(json, 'NodeList', <NodeLog>[], NodeLog());
    OrderInfo = setGenericFromJson(json, 'OrderInfo', Product(), "");
    OrderItemList = setGenericFromJson(
        json, 'OrderItemList', <OrderItemInfo>[], OrderItemInfo());
    AddressList =
        setGenericFromJson(json, 'AddressList', <Address>[], Address());
    OemAuditingList = setGenericFromJson(
        json, 'OemAuditingList', <OemAuditing>[], OemAuditing());
    IsUseOemAuditing = (json["IsUseOemAuditing"]?.toString()) ?? "0";
    OemAuditingProductList = setGenericFromJson(json, 'OemAuditingProductList',
        <OemAuditingProduct>[], OemAuditingProduct());
    ChangeFactoryId = json["ChangeFactoryId"] ?? "";
    ChangeFactoryName = json["ChangeFactoryName"] ?? "";
    //print("确认收款================${json['PayNoticeInfo']}");
    PayNoticeInfo = setGenericFromJson(json, 'PayNoticeInfo', PayNotice(), "");
    PayNoticeDetails = setGenericFromJson(
        json, 'PayNoticeDetails', <PayNoticeDetail>[], PayNoticeDetail());
    Receipt = setGenericFromJson(json, 'Receipt', ReceiptBean(), "");
    // print("=====================================================================已开发票：${json["ReceiptDetails"]}");
    ReceiptDetails = setGenericFromJson(
        json, 'ReceiptDetails', <ReceiptDetail>[], ReceiptDetail());
    ReceiptItemList = setGenericFromJson(
        json, 'ReceiptItemList', <ReceiptItem>[], ReceiptItem());
    // print("=====================================================================免款审核：${json["PayFreeInfo"]}");
    PayFreeInfo = setGenericFromJson(json, 'PayFreeInfo', PayFree(), "");
    PayFreeDetails = setGenericFromJson(
        json, 'PayFreeDetails', <PayFreeDetail>[], PayFreeDetail());
    PicList = setGenericFromJson(json, 'PicList', <String>[], "");
    BackToUserInfoList = setGenericFromJson(
        json, 'BackToUserInfoList', <NodeShow>[], NodeShow());
    //print("=====================================================================退回至：${json["BackToUserInfoList"]}");
    BackToUserInfo = setGenericFromJson(json, 'BackToUserInfo', NodeShow(), "");
    PayFreeReturn =
        setGenericFromJson(json, 'PayFreeReturn', PayFreeReturnBean(), "");
    PayFreeReturnList = setGenericFromJson(
        json, 'PayFreeReturnList', PayFreeReturnDetail1(), "");
    //PrintUtils.printlnLong("=====================================================================退货补片：${json["PayFreeGoodReturnList"]}");
    PayFreeGoodReturnList = setGenericFromJson(json, 'PayFreeGoodReturnList',
        <PayFreeGoodReturn>[], PayFreeGoodReturn());
    PayFreeReturnInfoList = setGenericFromJson(json, 'PayFreeReturnInfoList',
        <PayFreeReturnInfo>[], PayFreeReturnInfo());
    DeliveryInfo =
        setGenericFromJson(json, 'DeliveryInfo', DeliveryNotice(), "");
    DeliveryList =
        setGenericFromJson(json, 'DeliveryList', DeliveryList1(), "");
    CarFreight = setGenericFromJson(json, 'CarFreight', CarFreightRates(), "");
    WorkOvertimeApprovals = setGenericFromJson(json, 'WorkOvertimeApprovals',
        <WorkOvertimeApproval>[], WorkOvertimeApproval());
    OtherWorkApply =
        setGenericFromJson(json, 'OtherWorkApply', ContractCopyInfo(), "");
    Schedulings =
        setGenericFromJson(json, 'Schedulings', <Scheduling>[], Scheduling());
    PercentageCheck =
        setGenericFromJson(json, 'PercentageCheck', PercentageCheckBean(), "");
    ContractRoyaltyRateApplyCheck = setGenericFromJson(
        json,
        'ContractRoyaltyRateApplyCheck',
        ContractRoyaltyRateApplyCheckBean(),
        "");
    ContractFreightInfoList = setGenericFromJson(
        json,
        'ContractFreightInfoList',
        <ContractFreightInfo>[],
        ContractFreightInfo());
    addresslis = json["addresslis"] ?? "";
    FLoseApplyInfo =
        setGenericFromJson(json, 'FLoseApplyInfo', FLoseApplyInfoBean(), "");
    MaterialReviewInfo = setGenericFromJson(json, 'MaterialReviewInfo',
        <MaterialReviewInfoBean>[], MaterialReviewInfoBean());
    PurDemandInfo =
        setGenericFromJson(json, 'PurDemandInfo', ContractCopyInfo(), "");
    PurOrderInfo =
        setGenericFromJson(json, 'PurOrderInfo', PurOrderInfoBean(), "");
    PurContract =
        setGenericFromJson(json, 'PurContract', PurContractBean(), "");
    PurContractCompare =
        setGenericFromJson(json, 'PurContractCompare', PurContractBean(), "");
    TicketCenter = setGenericFromJson(
        json, 'TicketCenter', <EquipmentInfo>[], EquipmentInfo());
    Myworkorder = setGenericFromJson(
        json, 'Myworkorder', <EquipmentInfo>[], EquipmentInfo());
  }

  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map["Res"] = Res;
    map["MsgCode"] = MsgCode;
    map["MsgDetail"] = MsgDetail;
    map["StockNum"] = StockNum;
    map["TotalNum"] = TotalNum;
    map["TotalRowCount"] = TotalRowCount;
    map["Code"] = Code;
    map["MaxPage"] = MaxPage;
    map["TotalNum"] = TotalNum;
    setGenericToJson(map, 'Data', Data);
    map["ContractInfo"] = ContractInfo;
    map["WorkReview"] = WorkReview;
    map["CustomersInfo"] = CustomersInfo;
    map["ContractPaymentTermsCopy"] = ContractPaymentTermsCopy;
    map["ContractFinalPaymentCopy"] = ContractFinalPaymentCopy;
    map["SpecialClausesList"] = SpecialClausesList;
    map["FileList"] = FileList;
    map["ProductList"] = ProductList;
    map["NodeList"] = NodeList;
    map["OrderInfo"] = OrderInfo;
    map["OrderItemList"] = OrderItemList;
    map["AddressList"] = AddressList;
    map["OemAuditingList"] = OemAuditingList;
    map["IsUseOemAuditing"] = IsUseOemAuditing;
    map["OemAuditingProductList"] = OemAuditingProductList;
    map["ChangeFactoryId"] = ChangeFactoryId;
    map["ChangeFactoryName"] = ChangeFactoryName;
    map["PayNoticeInfo"] = PayNoticeInfo;
    map["PayNoticeDetails"] = PayNoticeDetails;
    map["Receipt"] = Receipt;
    map["ReceiptDetails"] = ReceiptDetails;
    map["ReceiptItemList"] = ReceiptItemList;
    map["PayFreeInfo"] = PayFreeInfo;
    map["PayFreeDetails"] = PayFreeDetails;
    map["PicList"] = PicList;
    map["BackToUserInfoList"] = BackToUserInfoList;
    map["BackToUserInfo"] = BackToUserInfo;
    map["PayFreeReturn"] = PayFreeReturn;
    map["PayFreeReturnList"] = PayFreeReturnList;
    map["PayFreeGoodReturnList"] = PayFreeGoodReturnList;
    map["PayFreeReturnInfoList"] = PayFreeReturnInfoList;
    map["DeliveryInfo"] = DeliveryInfo;
    map["DeliveryList"] = DeliveryList;
    map["CarFreight"] = CarFreight;
    map["WorkOvertimeApprovals"] = WorkOvertimeApprovals;
    map["OtherWorkApply"] = OtherWorkApply;
    map["Schedulings"] = Schedulings;
    map["Material"] = Material;
    map["ContractRoyaltyRateApplyCheck"] = ContractRoyaltyRateApplyCheck;
    map["ContractFreightInfoList"] = ContractFreightInfoList;
    map["addresslis"] = addresslis;
    map["FLoseApplyInfo"] = FLoseApplyInfo;
    map["MaterialReviewInfo"] = MaterialReviewInfo;
    map["PurDemandInfo"] = PurDemandInfo;
    map["PurOrderInfo"] = PurOrderInfo;
    map["PurContract"] = PurContract;
    map["LogisticsContract"] = LogisticsContract;
    map["PurContractCompare"] = PurContractCompare;
    return map;
  }

  @override
  String toString() {
    return 'AppHttpResult{Data: $Data, t2: $t2, MsgCode: $MsgCode, MsgDetail: $MsgDetail, Num: $Num, MaxPage: $MaxPage, TotalNum: $TotalNum}';
  }
}

///SubData提交信息
class SubData extends BaseBean {
  @override
  fromJson(Map json) {
    // TODO: implement fromJson
    commondata = json["commondata"] ?? null;
    pics = json["pics"]?.toString() ?? "";
    PageNo = json["PageNo"]?.toString() ?? "0";
    PageSize = json["PageSize"]?.toString() ?? "15";
    InsertStartDatetime = json["InsertStartDatetime"]?.toString();
    InsertEndDatetime = json["InsertEndDatetime"]?.toString();
    ReviewType = json["ReviewType"]?.toString();
    History = json["History"]?.toString();
    IsApproval = json["IsApproval"]?.toString() ?? "false";
    Status = json["Status"]?.toString();
    Intro = json["Intro"]?.toString();
    worktype = json["worktype"]?.toString();
    Type = json["Type"]?.toString();
    businessdata = json["businessdata"];
    CompareValue = json["CompareValue"];
    OverdueDateList = json["OverdueDateList"] != null
        ? json["OverdueDateList"].cast<String>()
        : [];
    InStoreHouse = json["InStoreHouse"];
    Checker = json["Checker"];
    PayFreeGoodReturnList = setGenericFromJson(json, 'PayFreeGoodReturnList',
        <SubPayFreeGoodReturn>[], SubPayFreeGoodReturn());
    PayFreeReturnList = setGenericFromJson(
        json, 'PayFreeReturnList', <SubPayFreeReturn>[], SubPayFreeReturn());
    Amount = json["Amount"]?.toString();
    MinWorkingHours = json["MinWorkingHours"]?.toString();
    YwxId = json["YwxId"]?.toString();
    YwxName = json["YwxName"]?.toString();
    Schedulings =
        setGenericFromJson(json, 'Schedulings', <Scheduling>[], Scheduling());
    WorkOvertimeApprovals = setGenericFromJson(json, 'WorkOvertimeApprovals',
        <WorkOvertimeApproval>[], WorkOvertimeApproval());
    purDemand = setGenericFromJson(json, 'purDemand', MaterialInfo(), "");
    PercentageCheckInfo = setGenericFromJson(json, 'PercentageCheckInfo',
        <PercentageCheckInfoBean>[], PercentageCheckInfoBean());
    ModifyContractRoyaltyRate = setGenericFromJson(
        json, "ModifyContractRoyaltyRate", ModifyContractRoyaltyRateBean(), "");
    FLoseApplyInfo =
        setGenericFromJson(json, "FLoseApplyInfo", FLoseApplyInfoBean(), "");
    isSecondaryConfirmation = json["isSecondaryConfirmation"] ?? false;
    MaterialReviewInfo = setGenericFromJson(json, 'MaterialReviewInfo',
        <MaterialReviewInfoBean>[], MaterialReviewInfoBean());
    wfId = json["wfId"];
  }

  @override
  instance() {
    // TODO: implement instance
    return SubData();
  }

  bool isEquipmentInfo = false; //是否返回工单中心，和我的工单数据。

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    map["commondata"] = commondata;
    map["pics"] = pics;
    map["PageNo"] = PageNo;
    map["PageSize"] = PageSize;
    map["InsertStartDatetime"] = InsertStartDatetime;
    map["InsertEndDatetime"] = InsertEndDatetime;
    map["ReviewType"] = ReviewType;
    map["History"] = History;
    map["IsApproval"] = IsApproval;
    map["Status"] = Status;
    map["IsAgree"] = IsAgree;
    map["Intro"] = Intro;
    map["worktype"] = worktype;
    map["Type"] = Type;
    //map["businessdata"] = getAsJson(businessdata);
    map["businessdata"] = businessdata;
    map["CompareValue"] = CompareValue;
    map["OverdueDateList"] = OverdueDateList;
    map["InStoreHouse"] = InStoreHouse;
    map["Checker"] = Checker;
    map["PayFreeGoodReturnList"] = PayFreeGoodReturnList;
    map["PayFreeReturnList"] = PayFreeReturnList;
    map["Amount"] = Amount;
    map["MinWorkingHours"] = MinWorkingHours;
    map["YwxId"] = YwxId;
    map["YwxName"] = YwxName;
    map["Schedulings"] = Schedulings;
    map["WorkOvertimeApprovals"] = WorkOvertimeApprovals;
    map["purDemand"] = purDemand;
    map["PercentageCheckInfo"] = PercentageCheckInfo;
    map["ModifyContractRoyaltyRate"] = ModifyContractRoyaltyRate;
    map["FLoseApplyInfo"] = FLoseApplyInfo;
    map["isSecondaryConfirmation"] = isSecondaryConfirmation;
    map["MaterialReviewInfo"] = MaterialReviewInfo;
    map["wfId"] = wfId;
    map["GetCheckPurDemand"] = GetCheckPurDemand;
    map["BodyId"] = BodyId;
    map["isEquipmentInfo"] = isEquipmentInfo;
    return map;
  }

  CommonData? commondata = null;

  Object? businessdata = null;
  String? BodyId = "";
  MaterialInfo? purDemand = null; //物料请购提交保存的数据。
  String? pics //图片地址（多张图片用|分隔）;fixme 目前有：免款审核
      = null;

  List<String> getPics() {
    if (StringUtils.isNotEmpty(pics)) {
      return pics!.split("|");
    }
    return [];
  }

  String? PageNo = "0"; //页码,从0开始。(物料请购是从1开始的，其他审核列表，是从0开始的)
  String PageSize = "15"; //每页显示条目数量
  String? InsertStartDatetime = ""; //提交开始时间
  String? InsertEndDatetime = ""; //提交结束时间
  String? ReviewType = ""; //提交类型

  String? History =
      "false"; // true 获取历史数据进行对比；false 和空 null 是获取正常数据;fixme 默认还是赋值为false,防止异常。
  String IsApproval = "false"; //是否已审核,服务器是字符串类型。

  String? Status = ""; //审批意见类型
  String? Intro = ""; //审批意见

  String? IsAgree = ""; //审批审核意见类型，和Status一样；主要在采购单审核里，有用到。

  String? worktype = null; //工种“02”  销售经理;“03”  客服经理
  String? Type = null; //开票审核提交：传：“NC” “金税”

  //fixme 以下是退货审核提交字段(提交，尽可能都提交id)

  bool isSecondaryConfirmation = false; //是否为二次确认提交

  //退回至（退货审核、免款审核,报损审核）
  String? CompareValue = null;

  //收款超期时间（确认收款）
  List<String?>? OverdueDateList = [];

  //入库仓库（退货补片）
  String? InStoreHouse = null;

  //检验员（退货补片）
  String? Checker = null;

  //参数列表（退货补片）
  List<SubPayFreeGoodReturn>? PayFreeGoodReturnList = null;

  //参数列表（退货审核）;责任工序；责任班组；责任人
  List<SubPayFreeReturn>? PayFreeReturnList = null;

  ///fixme 派工审核：申请金额
  String? Amount = ""; //金额：免款金额；退货金额;发票金额;实收金额

  String? MinWorkingHours = ""; //最少工作工时

  /// 业务项Id
  String? YwxId = null;

  ///业务项名称;fixme (在列表信息里有，详情里没有)；如：合同审核(部门审核)
  String? YwxName = null;

  ///fixme 加班审核：排班
  List<Scheduling>? Schedulings = null;

  ///fixme 加班审核:加班审批
  List<WorkOvertimeApproval>? WorkOvertimeApprovals = null;

  ///fixme 第二层：提成审核详情（客户名称，和项目名称）;主要提交：提成比例 和 预期扣除
  List<PercentageCheckInfoBean>? PercentageCheckInfo = null;

  //fixme ModifyContractRoyaltyRate 修改提成比例
  ModifyContractRoyaltyRateBean? ModifyContractRoyaltyRate = null;

  ///fixme 报损审核
  FLoseApplyInfoBean? FLoseApplyInfo = null;

  ///fixme 五金领用审核
  List<MaterialReviewInfoBean>? MaterialReviewInfo = null;

  ///fixme 请购单审核
  List<PurDemand>? GetCheckPurDemand = null;
  String? wfId = ""; //请购单审核撤回id
}

///CommonData公共信息
class CommonData extends BaseBean {
  String? barcode = ""; //条码
  String? processId = "00"; //工序
  String? versioncode = "1"; //应用版本号
  String? factoryId = ""; //工厂id

  CommonData() {
    AppUtils.getPackageInfo()
        .then((value) => {versioncode = value?.buildNumber ?? ""});
    factoryId = AppDataConfig.getFactory()?.FactoryId;
  }

  @override
  fromJson(Map json) {
    // TODO: implement fromJson
    barcode = json["barcode"] ?? "";
    processId = json["processId"] ?? "";
    versioncode = json["versioncode"] ?? "";
    factoryId = json["factoryId"] ?? "";
  }

  @override
  instance() {
    // TODO: implement instance
    return CommonData();
  }

  @override
  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map["barcode"] = barcode;
    map["processId"] = processId;
    map["versioncode"] = versioncode;
    map["factoryId"] = factoryId;
    return map;
  }
}

///工厂
class Factory extends RollerBean {
  String FactoryId = ""; //": 1, 工厂ID
  String FactoryName = ""; //": "江花玻璃（庄桥）"，工厂名称
  String FactoryURL = ""; //工厂MES系统url
  //
  // //fixme 以下是自己加的参数
  bool isSelect = false; //是否选中。

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    FactoryId = json["FactoryId"].toString() ?? "";
    FactoryName = json["FactoryName"] ?? "";
    FactoryURL = json["FactoryURL"] ?? "";
    isSelect = json["isSelect"] ?? false;
    key = FactoryId;
    value = FactoryName;
  }

  @override
  instance() {
    // TODO: implement instance
    return Factory();
  }

  @override
  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map["FactoryId"] = FactoryId;
    map["FactoryName"] = FactoryName;
    map["FactoryURL"] = FactoryURL;
    map["isSelect"] = isSelect;
    return map;
  }
}

/**
 * 服务器错误码
 * Created by 彭治铭 on 2019/3/20.
 */
class MsgCodes {
  static String code_100 = "100"; //	操作成功
  static String code_101 = "101"; //  操作失败
  static String code_102 = "102"; //	缺少参数；打卡签退，需要二次确认。
  static String code_103 = "103"; //	参数格式错误（如：非数字格式）；判断打卡签退二次确认后，是否还需要接口判断一次。
  static String code_104 = "104"; //	签名错误
  static String code_105 = "105"; //	系统错误（如：数据库错误、文件错误等）
  static String code_106 = "106"; //	用户身份不合法
  static String code_107 = "107"; //	仓位不合法（不是指定的仓位）
  static String code_108 = "108"; //	提示 "原片品牌不符，是否继续提交";
  static String code_200 = "200"; //	有补片玻璃需要并架
  static String code_201 = "201"; //	请等待退片玻璃处理完成
  static String code_202 = "202"; //	请先处理可接收的数量
  static String code_203 = "203"; //	合片工序的尚未配对成功
  static String code_204 = "204"; //	合片工序有配不齐的玻璃未移位
  static String code_300 = "300"; //	该架卡还不能生产，返回信息会显示其他可生产的架卡信息
  static String code_301 = "301"; //	该架卡（或补片）已结束生产，请手动选择要操作的工序
}

// {
// "barcode": "",
// "processId": "00",
// "versioncode": "1",
// "ContractCode": "HT20221116002"
// "ContractId": "HT20221116002"
// }
class ContractParams extends BaseBean {
  String barcode = "";
  String processId = "00";
  String versioncode = "1";
  String ContractCode = "";
  String ContractId = "";

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    barcode = json["barcode"].toString() ?? "";
    processId = json["processId"] ?? "00";
    versioncode = json["versioncode"] ?? "1";
    ContractCode = json["ContractCode"] ?? "";
    ContractId = json["ContractId"] ?? "";
  }

  @override
  instance() {
    // TODO: implement instance
    return ContractParams();
  }

  @override
  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map["barcode"] = barcode;
    map["processId"] = processId;
    map["versioncode"] = versioncode;
    map["ContractCode"] = ContractCode;
    map["ContractId"] = ContractId;
    return map;
  }
}
